package com.idata.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.Map;

/**
 * @File AssociationType.Java
 * @Modify Time      @Author    @Version    @Description
 * ------------      -------    --------    -----------
 * 2023/10/13         yd.j      1.0         None
 */
@Getter
@AllArgsConstructor
public enum AssociationTypeEnum {
    ALL("所有", 0),
    ID_CARD("身份证关联", 1),
    PHONE("手机号关联", 2),
    RELATIONSHIP("关系关联", 3),
    ;

    private final String desc;

    private final int code;

    private static final Map<Integer, AssociationTypeEnum> VALUES_FOR_CODE = new HashMap<>();

    static {
        for (AssociationTypeEnum associationTypeEnum : AssociationTypeEnum.values()) {
            VALUES_FOR_CODE.put(associationTypeEnum.getCode(), associationTypeEnum);
        }
    }

    @Nullable
    public static AssociationTypeEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        return VALUES_FOR_CODE.get(code);
    }

}
